package org.minbox.chapter.seata;

import org.minbox.chapter.seata.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 账户接口实现
 *
 * @author 恒宇少年
 */
@RestController
@RequestMapping("/account")
public class AccountController  {
    /**
     * 账户业务逻辑
     */
    @Autowired
    private AccountService accountService;

    @PostMapping("/deduction")
    public String deduction(Integer accountId, Double money)
    {
        boolean deduction = accountService.deduction(accountId, money);
        if(deduction){
            return  "余额扣除成功";
        }
        return  "余额扣除失败";
    }
}
